/**
 * 
 */
package hwchai.oom.entity.customer;

import java.util.LinkedList;

/**
 * @author Administrator
 *
 */
public abstract class Customer {

	private LinkedList<Long> accounts;
	private int defaultAcc = 0;
	
	private long cId;
	private String cPassword;
	
	private String cName;
	private String cIdentify;
	private String cPhone;
	private String cAddress;
	private String cCode;
	
	Customer(long id, String password, String name, String identify, String phone, String address, String code){
		setId(id);
		setPassword(password);
		setName(name);
		setIdentify(identify);
		setPhone(phone);
		setAddress(address);
		setCode(code);
		accounts = new LinkedList<Long>();
	}

	/**
	 * @return the cId
	 */
	public long getId() {
		return cId;
	}

	/**
	 * @param cId the cId to set
	 */
	public void setId(long cId) {
		this.cId = cId;
	}

	/**
	 * @return the cName
	 */
	public String getName() {
		return cName;
	}

	/**
	 * @param cName the cName to set
	 */
	public void setName(String cName) {
		this.cName = cName;
	}

	/**
	 * @return the cIdentify
	 */
	public String getIdentify() {
		return cIdentify;
	}

	/**
	 * @param cIdentify the cIdentify to set
	 */
	public void setIdentify(String cIdentify) {
		this.cIdentify = cIdentify;
	}

	/**
	 * @return the cphone
	 */
	public String getPhone() {
		return cPhone;
	}

	/**
	 * @param cphone the cphone to set
	 */
	public void setPhone(String cPhone) {
		this.cPhone = cPhone;
	}

	/**
	 * @return the cAddress
	 */
	public String getAddress() {
		return cAddress;
	}

	/**
	 * @param cAddress the cAddress to set
	 */
	public void setAddress(String cAddress) {
		this.cAddress = cAddress;
	}

	/**
	 * @return the cCode
	 */
	public String getCode() {
		return cCode;
	}

	/**
	 * @param cCode the cCode to set
	 */
	public void setCode(String cCode) {
		this.cCode = cCode;
	}
	
	boolean addAccount(Long aid){
		return accounts.add(aid);
	}
	
	public Long[] getAccountIds(){
		Long[] ids = new Long[accounts.size()];
		accounts.toArray(ids);
		return ids;
	}
	
	public boolean isContainsAccount(Long aid){
		return accounts.contains(aid);
	}

	/**
	 * @return the cPassword
	 */
	public String getPassword() {
		return cPassword;
	}

	/**
	 * @param cPassword the cPassword to set
	 */
	public void setPassword(String cPassword) {
		this.cPassword = cPassword;
	}
	
	/**
	 * @return the defaultAcc
	 */
	public Long getDefautAccount() {
		return accounts.get(defaultAcc);
	}

	/**
	 * @param defaultAcc the defaultAcc to set
	 */
	public void setDefaultAccount(int index) {
		this.defaultAcc = index;
	}
}
